package com.miyake.dsp.osa.lab.wrapper;


import com.miyake.dsp.ComplexArray;
import com.miyake.dsp.ScilabExecute;
import com.miyake.dsp.analyzer.FftSetting;
import com.miyake.dsp.osa.lab.Calculator;
import com.miyake.dsp.osa.lab.LabUiAnnotation;

@LabUiAnnotation(caption="FFT")
public class FftWrapper extends Calculator {
	public static final String INPUT_X = "INPUT X (time)";
	public static final String INPUT_Y = "INPUT Y";
	public static final String OUTPUT_X = "OUTPUT X (Frequency)";
	public static final String OUTPUT_Y = "OUTPUT Y";
	private FftSetting setting;
	
	public FftWrapper(FftSetting setting) {
		this.setting = setting;
		initInput(INPUT_X);
		initInput(INPUT_Y);
		initOutput(OUTPUT_X);
		initOutput(OUTPUT_Y);
	}
	
	public void setTimeDomain(double[] t) {
		setInput(INPUT_Y, new ComplexArray(t));
	}

	@Override
	public synchronized void process() {
		setOutput(OUTPUT_Y, ScilabExecute.execute("y=fft(data1);", getInput(INPUT_Y), "y"));
	}

	@Override
	public Object getSetting() {
		return setting;
	}
}
